dnl $Id$
dnl config.m4 for extension nmdb


PHP_ARG_WITH(nmdb, for nmdb support,
[  --with-nmdb   Include nmdb support])



if test "$PHP_NMDB" != "no"; then
  dnl # --with-nmdb -> check with-path
  SEARCH_PATH="/usr/local /usr"     # you might want to change this
  SEARCH_FOR="/include/nmdb.h"  # you most likely want to change this
  if test -r $PHP_NMDB/$SEARCH_FOR; then # path given as parameter
     NMDB_DIR=$PHP_NMDB
  else # search default path list
    AC_MSG_CHECKING([for nmdb files in default path])
    for i in $SEARCH_PATH ; do
      if test -r $i/$SEARCH_FOR; then
        NMDB_DIR=$i
        AC_MSG_RESULT(found in $i)
      fi
    done
  fi
 
  if test -z "$NMDB_DIR"; then
    AC_MSG_RESULT([not found])
    AC_MSG_ERROR([Please reinstall the nmdb distribution])
  fi

  dnl # --with-nmdb -> add include path
  PHP_ADD_INCLUDE($NMDB_DIR/include)

  dnl # --with-nmdb -> check for lib and symbol presence
  LIBNAME=nmdb # you may want to change this
  LIBSYMBOL=nmdb_init # you most likely want to change this 

  PHP_CHECK_LIBRARY($LIBNAME,$LIBSYMBOL,
  [
    PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $NMDB_DIR/lib, NMDB_SHARED_LIBADD)
    AC_DEFINE(HAVE_NMDBLIB,1,[ ])
  ],[
    AC_MSG_ERROR([wrong nmdb lib version or lib not found])
  ],[
    -L$NMDB_DIR/lib -lm -ldl
  ])
 
  PHP_SUBST(NMDB_SHARED_LIBADD)

  PHP_NEW_EXTENSION(nmdb, nmdb.c, $ext_shared)
fi
